<template>
  <div class="container-header">
    <div class="container-left">
      <Left @modelDrag="modelDrag" @modelDragEnd="modelDragEnd"></Left>
    </div>
    <div class="container-content">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div class="swiper-slide" @mousemove="sent(1)">
            <Content ref="content" :id="swiperId"></Content>
          </div>
          <div class="swiper-slide" @mousemove="sent(2)">
            <Msdn ref="msdn" :id="swiperId"></Msdn>
          </div>
          <div class="swiper-slide" @mousemove="sent(3)">{{ swiperId }}</div>
          <div class="swiper-slide" @mousemove="sent(4)">{{ swiperId }}</div>
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination"></div>
      </div>
    </div>
  </div>
</template>

<script>
import Content from "./Content.vue";
import Left from "./Left.vue";
import Msdn from "./Msdn.vue";
import Swiper from "swiper"; // 注意引入的是Swiper
import "swiper/css/swiper.min.css"; // 注意这里的引入
// import Right from "./Right.vue";
export default {
  mounted() {
    this.initSwiper();
  },
  data() {
    return {
      num: 123,
      params: {},
      id: 1,
      swiperId: 0,
    };
  },
  components: {
    Content,
    Left,
    Msdn,
  },
  methods: {
    sent(data) {
      this.swiperId = data;
      console.log(this.swiperId);
    },

    modelDrag(params) {
      if (this.swiperId === 1) {
        this.$refs.content.drag(params);
      } else if (this.swiperId === 2) {
        this.$refs.msdn.drag(params);
      }
    },
    modelDragEnd(params) {
      if (this.swiperId === 1) {
        this.$refs.content.dragend(params);
      } else if (this.swiperId === 2) {
        this.$refs.msdn.dragend(params);
      }
    },
    initSwiper() {
      new Swiper(".swiper-container", {
        direction: "vertical",
        slidesPerView: 1,
        spaceBetween: 30,
        mousewheel: true,
        pagination: {
          el: ".swiper-pagination",
          clickable: true,
        },
      });
    },
  },
};
</script>

<style scoped>
.container-header {
  width: 100%;
  height: 100%;

  display: flex;
  justify-content: space-around;
  align-items: center;
}

.container-left {
  width: 10%;
  height: 100vh;
  background-image: linear-gradient(to top, #fbc2eb 0%, #a6c1ee 100%);
}
.container-content {
  width: 70%;
  height: 100vh;
  background-color: pink;
  overflow: auto;
}
.swiper-container {
  width: 100%;
  height: 100%;
  margin-left: auto;
  margin-right: auto;
}
.swiper-slide {
  text-align: center;
  font-size: 18px;
  background-image: linear-gradient(-20deg, #e9defa 0%, #fbfcdb 100%);

  /* Center slide text vertically */
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}
</style>